<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: huangrulan
  Date: 2019/3/6
  Time: 1:39 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>场次信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="Author" content="larry"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="${base}/assets/images/favicon.ico">
    <link rel="stylesheet" type="text/css" href="${base}/assets/css/layui/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="${base}/assets/css/larryms/larryms.css" media="all">
    <link rel="stylesheet" type="text/css" href="${base}/larryms/css/admin/admin.css" media="all">
    <link rel="stylesheet" type="text/css" href="${base}/larryms/css/admin/article.css" media="all">
    <style>
        .auth-user-add .layui-form .layui-form-select .layui-select-title input.layui-input {
            background: #ffffff;
        }

        .layui-input-block {
            margin-left: 140px;
            min-height: 36px;
        }

        .layui-input, .layui-textarea {
            display: block;
            width: 100%;
            padding-left: 10px;
            background: #e8e8e8;
        }
    </style>
</head>
<body>
<div class="layui-fluid larryms-article">
    <div class="layui-tab-content larryms-panel-body auth-user-add">
        <div class="layui-form">
            <form id="userForm" class="layui-form"
                  action="${base}/ticket/order/save.json" enctype="multipart/form-data" method="post">

                <input type="hidden" name="id" value="${order.id}">

                <div class="layui-form-item">
                    <label class="layui-form-label"><font color="red">* </font>用户名</label>
                    <div class="layui-input-block">
                        <input type="text" name="userName" value="${order.userName}" disabled
                               class="layui-input larry-input" autocomplete="off" lay-verify="">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><font color="red">* </font>影片名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" value="${order.title}" disabled
                               class="layui-input larry-input" autocomplete="off" lay-verify="required">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><font color="red">* </font>下单时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="orderTime" disabled value="${order.orderTime}"
                               class="layui-input larry-input" autocomplete="off" lay-verify="required">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><font color="red">* </font>支付时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="payTime" disabled value="${order.payTime}"
                               class="layui-input larry-input" autocomplete="off" lay-verify="required">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><font color="red">* </font>电影票数量</label>
                    <div class="layui-input-block">
                        <input type="text" name="quantity" disabled value="${order.quantity}"
                               class="layui-input larry-input" autocomplete="off" lay-verify="required">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><font color="red">* </font>支付金额</label>
                    <div class="layui-input-block">
                        <input type="text" name="money" disabled value="${order.money }"
                               class="layui-input larry-input" autocomplete="off" lay-verify="required">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><font color="red">* </font>状态</label>
                    <div class="layui-input-block">
                        <select name="status" lay-verify="required">
                            <option value="1" <c:if test="${order.status == 0}">selected</c:if> disabled>未支付</option>
                            <option value="2" <c:if test="${order.status == 1}">selected</c:if> disabled>已支付</option>
                            <option value="3" <c:if test="${order.status == 9}">selected</c:if> disabled>取消订单</option>
                            <option value="4" <c:if test="${order.status == 2}">selected</c:if> <c:if test="${order.status != 1}">disabled</c:if>>退票</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><font color="red">* </font>座位号</label>
                    <div class="layui-input-block">
                        <input type="text" name="seatNo" disabled value="${order.seatNo}"
                               class="layui-input larry-input" autocomplete="off" lay-verify="required">
                    </div>
                </div>

                <div class="larryms-layer-btn center">
                    <a class="layui-btn" lay-submit lay-filter="saveOrder" id="submitAdd">确定</a>
                    <a class="layui-btn layui-btn-normal" id="resetAdd">重置</a>
                    <a class="layui-btn layui-btn-danger" id="closeAdd">关闭</a>
                </div>
            </form>
        </div>
    </div>
</div>


<!-- 加载js文件-->
<script type="text/javascript" src="${base}/assets/js/layui/layui.js"></script>
<script type="text/javascript" src="${base}/assets/js/layui/tableSelect.js"></script>
<script type="text/javascript">
    layui.config({
        version: "2.0.8",
        base: '${base}/larryms/',  //实际使用时，建议改成绝对路径
        identified: 'merge',
        // mods: 'vip/',
        page: 'order',
        layertype: 2,
        rightMenu: true // false关闭，设置为custom时使用自定义，不使用默认menu
    }).extend({
        larry: 'js/base'
    }).use(['larry', 'form', 'layer', 'laydate', 'table'], function () {
        var $ = layui.$,
            larry = layui.larry, layer = layui.layer, form = layui.form, laydate = layui.laydate, table = layui.table,
            tableSelect = layui.tableSelect;
        var curIfr = parent.layer.getFrameIndex(window.name);
        $('#resetAdd').on('click', function () {
            $('#slideForm')[0].reset();
        });
        $('#closeAdd').on('click', function () {
            parent.layer.close(curIfr);
        });

        console.log($('select[name=status]').val());

        //提交表单
        form.on('submit(saveOrder)', function (data) {
            console.log(data.field);
            $.ajax({
                type: 'POST',
                url: '${base}/ticket/order/save.json',
                dataType: 'json',
                data: data.field,
                async: true,
                success: function (res) {
                    console.log(res.success);
                    if (res.success) {
                        layer.msg(res.data, {icon: 1, time: 1500}, function () {
                            parent.layer.close(curIfr);
                            parent.location.href = "order.page";
                        });
                    } else {
                        layer.msg(res.msg, {icon: 5, time: 2000}, function () {
                            parent.layer.close(curIfr);
                            location.reload();
                        });
                    }
                }, error: function () {
                    layer.msg("请求失败，请联系开发人员", {icon: 5, time: 2000}, function () {
                        parent.layer.close(curIfr);
                        location.reload();
                    });
                }
            });
        });

    });
</script>
</body>
</html>
